#ifndef CAN_RECEIVE_H
#define CAN_RECEIVE_H

#include "struct_typedef.h"

#define CAN_1 hcan1
#define CAN_2 hcan2

/* 与云台C板的通讯ID标识*/
#define CAN_SENT_BROAD_TYPE_C 0x100
#define CAN_FROM_BROAD_TYPE_C 0x101

/* 超级电容功率板 ID标识 */
#define CAN_SUPERCAP_ID 0x888

/* 底盘电机 ID标识 */
#define CAN_CHASSIS_ALL_ID 0x200
#define CAN_3508_M1_ID 0x201
#define CAN_3508_M2_ID 0x202
#define CAN_3508_M3_ID 0x203
#define CAN_3508_M4_ID 0x204

/* 云台电机 ID标识 */
#define CAN_YAW_MOTOR_ID 0x205

//RoboMaster电机数据结构
typedef struct
{
    uint16_t ecd;         //霍尔编码值机械角度
    int16_t speed_rpm;    //转速
    int16_t given_current;//电流  
    uint8_t temperate;  //温度
    int16_t last_ecd;   //上一次机械角度
} motor_measure_t;

//C板接收数据
typedef struct
{
    int16_t chassis_vx;     //底盘前后速度
    int16_t chassis_vy;     //底盘左右速度
    int16_t chassis_wz;     //底盘旋转速度
    uint8_t chassis_mode;   //底盘控制模式
} receive_broad_c_t;

extern void CAN_cmd_chassis(int16_t motor1, int16_t motor2, int16_t motor3, int16_t motor4);//发送底盘电机控制电流CAN1(0x201,0x202,0x203,0x204)

extern const motor_measure_t *get_chassis_motor_measure_point(uint8_t i);//返回底盘电机 3508电机数据指针 电机编号i,范围[0,3]

extern const motor_measure_t *get_yaw_motor_measure_point(void);    //返回yaw 6020电机数据指针

extern const receive_broad_c_t *get_broad_type_c_data_point(void); //返回C板控制的数据指针

#endif
